package com.neusoft.chatserver.controller;


import com.neusoft.chatserver.dto.GroupCreate;
import com.neusoft.chatserver.dto.GroupModify;
import com.neusoft.chatserver.dto.RespBean;
import com.neusoft.chatserver.service.IChatGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liuxp
 * @since 2021-07-15
 */
@CrossOrigin
@RestController
@RequestMapping("/chat")
public class ChatGroupController {
    @Autowired
    IChatGroupService iChatGroupService;

    @PostMapping("/createGroup")
    RespBean createGroup(@RequestBody GroupCreate groupCreate){
        return iChatGroupService.createGroup(groupCreate);
    }

    @PostMapping("/addGroupMember")
    RespBean addGroupMember(@RequestBody GroupModify groupModify){
        return iChatGroupService.addGroupMember(groupModify);
    }
    @PostMapping("/deleteGroupMember")
    RespBean deleteGroupMember(@RequestBody GroupModify groupModify){
        return iChatGroupService.deleteGroupMember(groupModify);
    }

    @PostMapping("/getAllGroup/{userId}")
    RespBean getAllGroup(@PathVariable Integer userId){
        return iChatGroupService.getAllGroup(userId);
    }

    @PostMapping("getGroupMember/{groupId}")
    RespBean getGroupMember(@PathVariable Integer groupId){
        return iChatGroupService.getGroupMember(groupId);
    }
}

